package com.ctshk.rpc.scenic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.scenic.dto.ScenicProductCostStrategySpecStockDTO;
import com.ctshk.rpc.scenic.entity.ScenicProductCostStrategySpecStock;
import com.ctshk.rpc.scenic.entity.ScenicProductTicket;
import com.ctshk.rpc.scenic.req.ScenicProductCostStrategySpecStockReq;
import com.ctshk.rpc.scenic.req.ScenicResourceTicketReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 门票库存 Mapper 接口
 * </p>
 *
 * @author wangcy
 * @since 2021-02-02
 */
public interface ScenicProductCostStrategySpecStockMapper extends BaseMapper<ScenicProductCostStrategySpecStock> {

    @Select("SELECT * t_scenic_product_cost_strategy_spec_stock \n" +
            "WHERE  strategy_id = #{req.strategyId} and product_id \n" +
            " = #{req.productId} and attr1_name = #{req.attr1Name} \n" +
            " and attr2_name = #{req.attr2Name} limit 1")
    ScenicProductCostStrategySpecStockDTO queruDetail(@Param("req") ScenicProductCostStrategySpecStockReq req);


    @Select("SELECT * from t_scenic_product_cost_strategy_spec_stock \n" +
            "WHERE  id = #{id} ")
    ScenicProductCostStrategySpecStock queryById(@Param("id") Long id);

    @Select("select * from t_scenic_product_cost_strategy_spec_stock where strategy_id = #{strategyId} limit 1")
    ScenicProductCostStrategySpecStock queryByStrategyId(@Param("strategyId") Long strategyId);

    @Select("select * from t_scenic_product_cost_strategy_spec_stock where product_id = #{productId}")
    List<ScenicProductCostStrategySpecStock> quertByid(@Param("productId") Long productId);

    @Select("select * from t_scenic_product_cost_strategy_spec_stock where id = #{id}")
    ScenicProductCostStrategySpecStock quertByattrid(@Param("id") Long id);

    /**
     * 查询最少价格
     * @param productId
     * @return
     */
    @Select("select * from t_scenic_product_cost_strategy_spec_stock where product_id = #{productId} ORDER BY cost_price ASC")
    List<ScenicProductCostStrategySpecStock> quertCostPriceByid(@Param("productId") Long productId);
}
